
from tkinter import *

app = Tk()
app.title("模擬登錄系統")
app.geometry("900x380")

# 頁腳信息
copyright_lable = Label(app,text='廣雅中學 @ copyright')
copyright_lable.pack(side='bottom')

pic = r'C:/Users/a/Desktop/test01.gif'
canvas = Canvas(app)
image_file = PhotoImage(file = pic)
canvas.create_image(0, 0, anchor = "nw", image = image_file)
canvas.place(x = 0, y = 0, height = 360, width = 600)

login_title = Label(app, text = "模擬登錄頁面")
login_title.place(x = 620, y = 200)


# 用戶名相關
name_label = Label(app, text = "用戶名")
name_label.place(x = 620, y = 220)
name_input = Entry(app, textvariable = name_label, width = 20)
name_input.place(x = 670, y = 220)

password_label = Label(app, text = "密  碼")
password_label.place(x = 620, y = 248)
password_input = Entry(app, textvariable = password_label, width = 20)
password_input.place(x = 670, y = 248)

def test():
    msg = ""
    if (name_input.get() == '') | (password_input.get() == ''):
        msg = "用戶名和密碼不能為空"
        print(msg)
    elif (name_input.get() != "admin") or (password_input.get() != "111"):
        msg = "用戶名或者密碼錯誤"
        print(msg)
    elif (name_input.get() == "admin") & (password_input.get() == "111"):
        msg = "登錄成功"
        print(msg)

    msg = msg.center(14, "=")

    login_info_label = Label(app, text = msg)
    login_info_label.place(x = 620, y = 275)


login_button = Button(app, text = "登錄", command = test)
login_button.place(x = 620, y = 300)

login_quit = Button(app, text = "退出", command = app.quit)
login_quit.place(x = 660, y = 300)

app.mainloop()